package com.tianji.promotion.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.promotion.domain.po.Coupon;
import com.tianji.promotion.domain.po.UserCoupon;
import com.tianji.promotion.domain.query.CouponQuery;
import com.tianji.promotion.domain.query.UserCouponQuery;
import com.tianji.promotion.domain.vo.CouponVO;
import com.tianji.promotion.service.ICouponService;
import com.tianji.promotion.service.IUserCouponService;
import io.swagger.annotations.ApiOperation;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户领取优惠券的记录，是真正使用的优惠券信息 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-29
 */
@Slf4j
@RestController
@RequestMapping("/user-coupons")
@RequiredArgsConstructor
public class UserCouponController {

    private final IUserCouponService ucService;

    /**
     * 用户领取优惠券
     * @param id
     */
    @ApiOperation("用户领取优惠券")
    @PostMapping("/{id}/receive")
    public void receiveCoupon(@PathVariable Long id) {
        ucService.receiveCoupon(id);
    }

    /**
     * 分页查询用户优惠券
     * @param ucQuery
     */
    @ApiOperation("分页查询用户优惠券")
    @GetMapping("/page")
    public PageDTO<UserCoupon> listVO(UserCouponQuery ucQuery) {
        return ucService.pageQuery(ucQuery);
    }

    /**
     * 兑换码兑换优惠卷
     */
    @ApiOperation("兑换优惠卷接口")
    @PostMapping("/{ecode}/exchange")
    public void getDetailById(@PathVariable("ecode") String ecode ) {
        System.out.println("兑换码为" + ecode);
        ucService.exchangeByCode(ecode);
    }



}
